﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ehmaParinguVahemik", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(EhmaParinguVahemik))]
    public class EhmaParinguVahemikSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEhmaParinguVahemik clazz;
        
        public EhmaParinguVahemikSerializer(IEhmaParinguVahemik clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("startd");
            if (clazz.Startd!=null) {
                Writer.WriteTypeAttribute("http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", ">>ehmaParinguVahemik>startd");
                Writer.WriteString(clazz.Startd.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Startd");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("endd");
            if (clazz.Endd!=null) {
                Writer.WriteTypeAttribute("http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", ">>ehmaParinguVahemik>endd");
                Writer.WriteString(clazz.Endd.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Endd");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="startd") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ehmaParinguVahemik>startd");
                }
                clazz.Startd = new EhmaParinguVahemik.StartdType(Reader.ReadElementString("startd"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ehmaParinguVahemik>startd", Reader.LocalName);
            }
            if (Reader.LocalName=="endd") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ehmaParinguVahemik>endd");
                }
                clazz.Endd = new EhmaParinguVahemik.EnddType(Reader.ReadElementString("endd"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ehmaParinguVahemik>endd", Reader.LocalName);
            }
        }
    }
}
